package com.template.mongo.service;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.security.core.context.SecurityContext;

import com.template.mongo.persistence.entity.Account;
import com.template.mongo.utils.PagingInfo;

public interface UserService {
	
	Account findByUserName(String userName);

	List<Account> findByEmail(String email);

	Account findByMobile(String mobile);
	
	boolean checkEmail(String email);

	List<Account> findByLevel(int level);

	List<Account> findByIsActive(short isActive);
	
	List<Account> findAll();
	
	List<Account> findByProperty(String property, Object value);

	/*
	 * Get current logging in user
	 */
	Account getCurrentLoggedInUser();

	/*
	 * Get current context of spring security
	 */
	SecurityContext getSecurityContext();

	/**
	 * Authenticate user with the request instance to interact with Session
	 * 
	 * @param userName
	 * @param password
	 * @param request
	 * @return true/false
	 */
	boolean authenticate(String userName, String password,
			HttpServletRequest request);

	/**
	 * authenticate user with simple user/pwd pair
	 * 
	 * @param userName
	 * @param pwd
	 * @return true/false
	 */
	boolean authenticate(String userName, String pwd);

	void save(Account u);

	/**
	 * Update an existing user
	 * 
	 * @param user
	 *            with changed information
	 */
	void update(Account u);
	/**
	 * @param userName
	 * @param isActive
	 */
	void deleteUser(String userName, boolean isActive);
	
	boolean delete(String userName);

	/**
	 * Check whether user usrName exist in db
	 * 
	 * @param usrName
	 * @return
	 */
	boolean checkExists(String usrName);

	Account findUserByEmail(String email);

	boolean savePwd(String u, String pwd);

	List<Account> getAllUsers(PagingInfo pInfo);

	List<Account> getUsers(String kw, PagingInfo pInfo);
	
	List<Account> getUsers(String kw, long departmentId, PagingInfo pInfo);

	boolean checkUserNameIgnore(String userName , String userNameOld);
}
